]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Remove st_container_remove_all & rewrite st_container_destroy_children
authorMaxim Ermilov <zaspire@rambler.ru>
Mon, 31 Jan 2011 23:25:35 +0000 (02:25 +0300)
committerMaxim Ermilov <zaspire@rambler.ru>
Tue, 1 Feb 2011 20:41:21 +0000 (23:41 +0300)
1. Both functions leaked the nodes in priv->children
2. st_container_remove_all wasn't properly updating first_child and last_child
3. remove_all() is almost never right since it won't cause signal handlers
   on the children to be removed. In the rare cases where it might be needed
   the caller can simply use clutter_container_remove().
https://bugzilla.gnome.org/show_bug.cgi?id=640781

js/ui/dash.js
js/ui/endSessionDialog.js
js/ui/modalDialog.js
js/ui/workspacesView.js
src/st/st-container.c
src/st/st-container.h

index 01de6af44c4c4faa1bfb28e57b9a1402a2860884..7e6ce1d538be3267ac42483eff5631a69cedfba1 100644 (file)
@@ -206,7 +206,7 @@ Dash.prototype = {
 
     _redisplay: function () {
         this._box.hide();
-        this._box.remove_all();
+        this._box.destroy_children();
 
         let favorites = AppFavorites.getAppFavorites().getFavoriteMap();
 
index 62b69b12bd8a711dd1ef37cb356a1284590e5a12..c25633ac22340b155cbfe3a1edd42848a79d9373 100644 (file)
@@ -470,7 +470,7 @@ EndSessionDialog.prototype = {
     OpenAsync: function(type, timestamp, totalSecondsToStayOpen, inhibitorObjectPaths, callback) {
         this._totalSecondsToStayOpen = totalSecondsToStayOpen;
         this._inhibitors = [];
-        this._applicationList.remove_all();
+        this._applicationList.destroy_children();
         this._type = type;
 
         if (!(this._type in DialogContent))
index 7b3f0d36ff57deb99e026e191e55681cec493a9c..fee62662a2963ce06d68de3286176abf88cc2320 100644 (file)
@@ -83,7 +83,7 @@ ModalDialog.prototype = {
     },
 
     setButtons: function(buttons) {
-        this._buttonLayout.remove_all();
+        this._buttonLayout.destroy_children();
         let i = 0;
         for (let index in buttons) {
             let buttonInfo = buttons[index];
index f53db7aea9767e657ae77c367367994b02b32d48..2a6557b47ce197dbfe75b39bb95fd2b8de1008b8 100644 (file)
@@ -769,7 +769,7 @@ WorkspaceIndicatorPanel.prototype = {
         else
             this.actor.set_skip_paint(this._box, false);
 
-        this._box.remove_all();
+        this._box.destroy_children();
         for (let i = 0; i < this._workspaces.length; i++) {
             let actor = new St.Button({ style_class: 'workspace-indicator',
                                         track_hover: true });
index 0fb5eb46273314246aa3f519fab7bbb00ab4f0d9..2f7d095b18bd635d71091daf30ffb5cc77684708 100644 (file)
@@ -35,6 +35,7 @@ struct _StContainerPrivate
   GList *children;
   ClutterActor *first_child;
   ClutterActor *last_child;
+  gboolean block_update_pseude_classes;
 };
 
 static void clutter_container_iface_init (ClutterContainerIface *iface);
@@ -50,6 +51,9 @@ st_container_update_pseudo_classes (StContainer *container)
   ClutterActor *first_child, *last_child;
   StContainerPrivate *priv = container->priv;
 
+  if (priv->block_update_pseude_classes)
+    return;
+
   first_item = priv->children;
   first_child = first_item ? first_item->data : NULL;
   if (first_child != priv->first_child)
@@ -91,28 +95,6 @@ st_container_update_pseudo_classes (StContainer *container)
     }
 }
 
-/**
- * st_container_remove_all:
- * @container: An #StContainer
- *
- * Removes all child actors from @container.
- */
-void
-st_container_remove_all (StContainer *container)
-{
-  StContainerPrivate *priv = container->priv;
-
-  /* copied from clutter_group_remove_all() */
-  while (priv->children)
-    {
-      ClutterActor *child = priv->children->data;
-      priv->children = priv->children->next;
-
-      clutter_container_remove_actor (CLUTTER_CONTAINER (container), child);
-    }
-  st_container_update_pseudo_classes (container);
-}
-
 /**
  * st_container_destroy_children:
  * @container: An #StContainer
@@ -124,13 +106,14 @@ st_container_destroy_children (StContainer *container)
 {
   StContainerPrivate *priv = container->priv;
 
+  priv->block_update_pseude_classes = TRUE;
+
   while (priv->children)
-    {
-      ClutterActor *child = priv->children->data;
-      priv->children = priv->children->next;
+    clutter_actor_destroy (priv->children->data);
 
-      clutter_actor_destroy (child);
-    }
+  priv->block_update_pseude_classes = FALSE;
+
+  st_container_update_pseudo_classes (container);
 }
 
 void
index 91f457f26142920e0027505c1e076fb80d282ae5..023bef9217eec48102cc60b11c2416958beb66d5 100644 (file)
@@ -53,7 +53,6 @@ struct _StContainerClass {
 
 GType   st_container_get_type             (void) G_GNUC_CONST;
 
-void    st_container_remove_all           (StContainer *container);
 void    st_container_destroy_children     (StContainer *container);
 
 GList * st_container_get_focus_chain      (StContainer *container);